<form [formGroup]="form"  class="great-form" (ngSubmit)="submitForm()">
  <div class="great-form-group">
    <label>最多10个字节:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="byteLength"><span [innerHtml]="'this.validator.byteLength({maxLength:10})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('byteLength').dirty && form.get('byteLength').errors">最多10个字节！</div>
    </div>
  </div>
  <div class="great-form-group">
    <label>必须10个字节:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="byteLength1"><span [innerHtml]="'this.validator.byteLength({length:10})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('byteLength1').dirty && form.get('byteLength1').errors">必须10个字节！</div>
    </div>
  </div>
  <div class="great-form-group">
    <label>最少10个字节:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="byteLength2"><span [innerHtml]="'this.validator.byteLength({minLength:10})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('byteLength2').dirty && form.get('byteLength2').errors">最少10个字节！</div>
    </div>
  </div>
  <div class="great-form-group">
    <label>5-10个字节:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="byteLength3"><span [innerHtml]="'this.validator.byteLength({minLength:10, maxLength:10})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('byteLength3').dirty && form.get('byteLength3').errors"> 5-10个字节  </div>
    </div>
  </div>
  <div class="great-form-group">
    <label>指定错误消息:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="byteLength4">
      <span [innerHtml]="'this.validator.byteLength({minLength:5, errorMsg: \'最少输入5个字节\'})'"></span>
      <span [innerHtml]="'this.validator.byteLength({maxLength:10, errorMsg: \'最多输入10个字节\'})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('byteLength4').dirty && form.get('byteLength4').errors"> {{form.get('byteLength4').errors.pattern.error}}  </div>
    </div>
  </div>
  <div class="great-form-group">
    <div class="great-form-bottom">
      <button type="submit">保 存</button>
    </div>
  </div>
</form>
